#ifndef MESH_H
#define MESH_H

//Scene manager stuff
#include "Ray.h"
#include "VertexFormat.h"

//tool stuff
#include "d3dUtil.h"
#include "ConstValueUtil.h"
#include "Logger.h"

//Mesh stuff
#include "Bone.h"
#include "Face.h"
#include "VertexWeight.h"
#include "MaterialInfo.h"
#include "BoundingBox.h"

class Mesh
{
public:
	Mesh(void);
	~Mesh(void);

	ID3D10Buffer*		GetVertexBuffer();
	ID3D10Buffer*		GetIndexBuffer();
	int					GetNumFaces();
	int					GetNumVerteices();
	MaterialInfo*		GetMaterialInfo();

	//give a ray in the mesh's local space,
	//determine if the ray intersect with
	//the mesh's AABB bounding box
	bool				Intersect(const Ray& ray);

	//return the mesh's center point  on the basis of it's bounding box
	D3DXVECTOR3			GetCenterPoint();

	void				BuildBuffer();
	void				ReleaseBuffer();
private:
	void BuildVertexBuffer();
	void BuildIndexBuffer();
	//build the mesh's AABB bounding box
	void BuildBoundingBox();

private:
	ID3D10Device*				m_pDeivce;
	std::string					m_strName;
	int							m_iMeshID;
	int							m_iNumBones;
	int							m_iNumVerteices;
	int							m_iNumFaces;

	MaterialInfo				m_MaterialInfo;

	std::vector<Bone>			m_lstBones;
	std::vector<D3DXVECTOR3>	m_lstVertexTangent;
	std::vector<MeshVertex>		m_lstVertex;
	std::vector<DWORD>			m_lstIndex;
	std::vector<Face>			m_lstFaces;

	BoundingBox					m_BoundingBox;

	ID3D10Buffer*				m_pVertexBuffer;
	ID3D10Buffer*				m_pIndexBuffer;

	D3DXVECTOR3					m_vec3CenterPoint;

	friend class ResourcesManager;
	//friend class Chess;
};


#endif

